<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2021/4/21
  Time: 3:54 下午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div class="container" style="text-align: center">
    <ul class="pagination">
        <c:if test="${pageInfo.pageNum>1}">
            <li><a href="javascript:nextPage(${pageInfo.pageNum-1})">&laquo;</a></li>
        </c:if>

        <c:if test="${pageInfo.pageNum<=1}">
            <li class="disabled"><a>&laquo;</a></li>
        </c:if>


        <c:set var="start" value="${pageInfo.pageNum}"></c:set>

        <c:if test="${pageInfo.pageNum+2<=pageInfo.pages}">
            <c:set var="end" value="${pageInfo.pageNum+2}"></c:set>
        </c:if>

        <c:if test="${pageInfo.pageNum+2>pageInfo.pages}">
            <c:set var="start" value="${pageInfo.pages-2}"></c:set>
            <c:set var="end" value="${pageInfo.pages}"></c:set>
        </c:if>


        <c:forEach begin="${start<=0?1:start}" end="${end}" var="n">
            <c:if test="${pageInfo.pageNum==n}">
                <li class="active"><a href="javascript:nextPage(${n})">${n}</a></li>
            </c:if>
            <c:if test="${pageInfo.pageNum!=n}">
                <li><a href="javascript:nextPage(${n})">${n}</a></li>
            </c:if>
        </c:forEach>

        <c:if test="${pageInfo.pageNum<pageInfo.pages}">
            <li><a href="javascript:nextPage(${pageInfo.pageNum+1})">&raquo;</a></li>
        </c:if>

        <c:if test="${pageInfo.pageNum>=pageInfo.pages}">
            <li class="disabled"><a>&raquo;</a></li>
        </c:if>


        <li><a>当前页${pageInfo.pageNum}/${pageInfo.pages}总页</a></li>
    </ul>
</div>
<script>
    function nextPage(pageNow){
        let value = document.getElementById("searchName").value;
        let select_type = document.getElementById("select_type");
        let typeId="-1"
        let minPrice="0";
        if(select_type!=null){
            typeId = select_type.value;
        }

        let min_price = document.getElementById("min_price");
        if(min_price!=null){
            minPrice = min_price.value;
        }
        window.location="/boot/car/index?pageNow="+pageNow+"&searchName="+value+"&typeId="+typeId+"&count=1&minPrice="+minPrice;
    }
</script>
